package com.kpf.springcloud.controller;

import com.kpf.springcloud.common.ResultJson;
import com.kpf.springcloud.config.AliyunConfig;
import com.kpf.springcloud.config.CommonUtils;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author shiwen
 * @date 2021/2/28
 */
@RestController
@Api(value = "通用工具接口", description = "通用工具接口") //swagger接口配置
public class CommonConsumerController {

    /**
     * 上传图片接口
     *
     * @param upload
     * @return
     */
    @PostMapping("/consumer/common/uploadFile")
    public ResultJson<String> uploadFile(@RequestParam("upload") MultipartFile upload, HttpServletRequest request){
        String path = CommonUtils.uploadFile(upload);
        return ResultJson.ok(path);
    }

    @PostMapping("/consumer/common/scanText")
    public ResultJson<Boolean> scanText(@RequestParam("context") String context) {
        return ResultJson.ok(AliyunConfig.scanText(context));
    }

}